<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>待我审批</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no,email=no" />
		<link rel="stylesheet" href="../css/mui.min.css">			
		<link rel="stylesheet" type="text/css" href="../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../fonts/iconfont.css" />
		<link rel="stylesheet" href="../css/OA.css" />
		
	</head>
	<body>
		<script src="../js/mui.min.js"></script>
		<script src="../js/mui.picker.min.js"></script>
		<script src="../js/app.js"></script>
		<script type="text/javascript" charset="utf-8">
			 
					
		</script>
		<style>
			
		</style>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">待我审批</h1>
		</header>
		<div class="mui-content transparent">
			<div style="padding: 10px 10px;">
                <div id="segmentedControl" class="mui-segmented-control">
                    <a class="mui-control-item mui-active" href="#item1">
                		待我审批
           			</a>
                    <a class="mui-control-item" href="#item2">
               		 	我已审批
           			</a>
                    
                </div>
            </div>
            <div>
                <div id="item1" class="mui-control-content mui-active">
                    <ul class="mui-table-view" id='row1'>
						<!--<li class="mui-table-view-cell mui-media">
							<a data-href="www.baidu.com/con?1" class="c-href"> 
								<span class="mui-media-object mui-pull-left iconfont icon-gongzuo"></span>
								<div class="mui-media-body">
									<div class="name-time">
									<span class="user-name">小鱼的<span ="">加班</span></span><span class="user-time">2014/12/10</span>
									</div>
									<p class='mui-ellipsis'>未审批</p>
								</div>
							</a>
						</li>	
						<li class="mui-table-view-cell mui-media">
							<a data-href="www.baidu.com/con?1" class="c-href"> 
								<span class="mui-media-object mui-pull-left iconfont icon-gongzuo"></span>
								<div class="mui-media-body">
									<div class="name-time">
									<span class="user-name">小鱼的<span ="">加班</span></span><span class="user-time">2014/12/10</span>
									</div>
									<p class='mui-ellipsis'>未审批</p>
								</div>
							</a>
						</li>-->
					</ul>
                </div>
                <div id="item2" class="mui-control-content">
                    <ul class="mui-table-view" id='row2'>
						<!--<li class="mui-table-view-cell mui-media">
							<a data-href="www.baidu.com/cn?1" class="c-href"> 
								<span class="mui-media-object mui-pull-left iconfont icon-qingjia2"></span>
								<div class="mui-media-body">
									<div class="name-time">
									<span class="user-name">小熊的<span ="">请假</span></span><span class="user-time">2014/12/10</span>
									</div>
									<p class='mui-ellipsis'>审批拒绝</p>
								</div>
							</a>
						</li>	
						<li class="mui-table-view-cell mui-media">
							<a data-href="www.baidu.com/cn?1" class="c-href"> 
								<span class="mui-media-object mui-pull-left iconfont icon-gongzuo"></span>
								<div class="mui-media-body">
									<div class="name-time">
									<span class="user-name">小熊的<span ="">加班</span></span><span class="user-time">2014/12/10</span>
									</div>
									<p class='mui-ellipsis'>审批同意</p>
								</div>
							</a>
						</li>-->
					</ul>
                </div>            
            </div>
           
            
			
			
		</div>
		
		<script>
			//选项卡
			 mui.init({
                swipeBack: true //启用右滑关闭功能
            });
            (function($) {
                $('#scroll').scroll({
                    indicators: true //是否显示滚动条
                });
                var segmentedControl = document.getElementById('segmentedControl');
                $('.mui-input-group').on('change', 'input', function() {
                    if (this.checked) {
                        var styleEl = document.querySelector('input[name="style"]:checked');
                        var colorEl = document.querySelector('input[name="color"]:checked');
                        if (styleEl && colorEl) {
                            var style = styleEl.value;
                            var color = colorEl.value;
                            segmentedControl.className = 'mui-segmented-control' + (style ? (' mui-segmented-' + style) : '') + ' mui-segmented-' + color;
                        }
                    }
                });
            })(mui);
			mui.plusReady(function() { 
				/*页面跳转*/
				mui('.mui-content').on('tap', '.c-href', function() {
						
						var href=this.getAttribute('data-href').toLowerCase(),
							id;
						console.log('成功');
						if(href.indexOf('com')>=0){
							id=href.split('com/?')[1]; 
							console.log(id); 
//							showProduct(id);
						 	himall.openVW('waiting-msg.html','',{eventId:id});
							console.log("进来了"); 
							
						}
						if(href.indexOf('cn')>=0){
							id=href.split('cn/?')[1]; 
							console.log(id); 
//							showProduct(id);
						 	himall.openVW('start-msg.html','',{topicId:id});
							console.log("进来了"); 
							
						} 
						else{
							plus.runtime.openURL(href);
							
						}
				});
				//请求数据
				var item1=document.getElementById('row1');
				var item2=document.getElementById('row2');
				
				mui.ajax(url+'OA/GetAudingExamine',{
								dataType:'json',
								type:'get',
								data:{
									userId:549,
									webToken:'rqlh'
									},
								timeout:10000,
								success:function(data){									
									if(data.Code=="000"){
										var dataLen=data.Data.length;
										var row='';
										var row2='';
										console.log(data.Data)
										console.log("请求成功");
										for (var i = 0; i < dataLen; i++) {
											var icon;
											/*截取类型*/
											var type=data.Data[i].examineType.substr(0,2);
											/*截取审批时间*/
											
											if(data.Data[i].status=='未操作'){
												if(data.Data[i].examineType==="请假申请"){
						            			icon="icon-qingjia2";						            			
							            		}						            		
							            		if(data.Data[i].examineType==="加班申请"){
							            			icon="icon-gongzuo";
							            			
							            		}
							            	 	if(data.Data[i].examineType==="报销申请"){
							            			icon="icon-baoxiao2";
							            		}
							            		row += '<li class="mui-table-view-cell mui-media">'
							            			+'<a class="c-href" data-href="www.baidu.com/?'+data.Data[i].examineId+'">'
							            			+'<span  class="mui-media-object mui-pull-left iconfont '+icon+' "></span>'
							            			+'<div class="mui-media-body"><div class="name-time"><span class="user-name">'+data.Data[i].userName+'的<span>'+data.Data[i].examineType+'</span></span>'
							                		+'<span class="user-time">'+time+'</span></div><p class="mui-ellipsis">审批<span>'+data.Data[i].status+'</span></p>'
													+'</div></a></li>'
											}else{
												var time=data.Data[i].examineDate.substr(0, 10);
												if(data.Data[i].examineType==="请假申请"){
						            			icon="icon-qingjia2";						            			
							            		}						            		
							            		if(data.Data[i].examineType==="加班申请"){
							            			icon="icon-gongzuo";
							            			
							            		}
							            	 	if(data.Data[i].examineType==="报销申请"){
							            			icon="icon-baoxiao2";
							            		}
							            		row2 += '<li class="mui-table-view-cell mui-media">'
							            			+'<a class="c-href" data-href="www.baidu.cn/?'+data.Data[i].eventId+'">'
							            			+'<span  class="mui-media-object mui-pull-left iconfont '+icon+' "></span>'
							            			+'<div class="mui-media-body"><div class="name-time"><span class="user-name">'+data.Data[i].userName+'的<span>'+data.Data[i].examineType+'</span></span>'
							                		+'<span class="user-time">'+time+'</span></div><p class="mui-ellipsis">审批<span>'+data.Data[i].status+'</span></p>'
													+'</div></a></li>'
											}
						            														
										}
										console.log(row);
										item1.innerHTML=row;
										item2.innerHTML=row2;
//										
									}else{
										plus.nativeUI.toast(data.Msg);
									}
								},
								error:function(xhr,type,errorThrown){
									plus.nativeUI.toast("连接服务器失败,请检查网络");
									   
								}
								   
									  
					}); 
			})
			
		</script>
	</body>
</html>
